﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WeatherAppService
{
    public static class Converter
    {
        public static Post PostEntityToPost(PostEntity postEntity)
        {
            Post post = new Post();
            post.PostId = postEntity.PostId.ToString();
            post.PostLocation = postEntity.PostLocation;
            post.PostMessage = postEntity.PostMessage;
            post.PostTime = postEntity.PostTime.ToString();
            post.UserName = postEntity.UserName;
            return post;
        }

        public static PostEntity PostToPostEntity(Post post)
        {
            PostEntity postEntity = new PostEntity();
            postEntity.PostLocation = post.PostLocation;
            postEntity.PostMessage = post.PostMessage;
            postEntity.PostTime = DateTime.Now;
            postEntity.UserName = post.UserName;
            return postEntity;
        }

        public static UserEntity UserToUserEntity(User user)
        {
            UserEntity userEntity = new UserEntity();
            userEntity.UserName = user.UserName;
            userEntity.Password = user.Password;
            userEntity.FirstName = user.FirstName;
            userEntity.LastName = user.LastName;
            userEntity.Email = user.Email;
            return userEntity;
        }

        public static User UserEntityToUser(UserEntity userEntity)
        {
            User user = new User();
            user.UserId = userEntity.UserId.ToString();
            user.UserName = userEntity.UserName;
            user.Password = userEntity.Password;
            user.FirstName = userEntity.FirstName;
            user.LastName = userEntity.LastName;
            user.Email = userEntity.Email;
            return user;
        }
    }
}